home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 API Bible / Windows 95 API Bible 3 Disc Set.iso / Win32 API Bible Book 3 of 3 / CHAPTE10 / STSMSGS / LINE.C < prev    next >
C/C++ Source or Header  |  1996-04-28  |  26KB  |  789 lines

  1.  
  2. #include <windows.h> 
  3. #include <windowsx.h> 
  4. #include "line.h" 
  5. #include "tapi.h"
  6.  
  7. #define BUFSIZE 256
  8. #define APIHIVERSION     0x00010028    /* 1.40 */
  9. #define APILOWVERSION    0x00010000    /* 1.0 */
  10. #define EXTHIVERSION     0x00010005    /* 1.5 */
  11. #define EXTLOWVERSION    0x00000009    /* 0.9 */ 
  12. #define OWNER        0
  13. #define MONITOR      1
  14. #define MAX_CALL        3
  15. #define MAX_LINE        2
  16.  
  17.  
  18. #if defined (WIN32)
  19.     #define IS_WIN32 TRUE
  20. #else
  21.     #define IS_WIN32 FALSE
  22. #endif
  23.  
  24. #define IS_NT      IS_WIN32 && (BOOL)(GetVersion() < 0x80000000)
  25. #define IS_WIN32S  IS_WIN32 && (BOOL)(!(IS_NT) && (LOBYTE(LOWORD(GetVersion()))<4))
  26. #define IS_WIN95   (BOOL)(!(IS_NT) && !(IS_WIN32S)) && IS_WIN32
  27.  
  28. LPCTSTR lpszAppName = "lineGetStatusMessages";
  29. LPCTSTR lpszTitle   = "lineGetStatusMessages"; 
  30.  
  31. HINSTANCE hInst;   // current instance
  32. HWND hWnd;         // parent window handle
  33. HWND hListWnd;     // listbox
  34. HDC  hdc;
  35. TEXTMETRIC  tm ;
  36.  
  37. BOOL RegisterWin95( CONST WNDCLASS* lpwc );
  38.  
  39.  
  40. int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
  41.                       LPTSTR lpCmdLine, int nCmdShow)
  42. {
  43.    MSG      msg;
  44.    WNDCLASS wc;
  45.  
  46.    wc.style         = CS_HREDRAW | CS_VREDRAW;
  47.    wc.lpfnWndProc   = (WNDPROC)WndProc;       
  48.    wc.cbClsExtra    = 0;                      
  49.    wc.cbWndExtra    = 0;                      
  50.    wc.hInstance     = hInstance;              
  51.    wc.hIcon         = LoadIcon (hInstance, lpszAppName); 
  52.    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
  53.    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
  54.    wc.lpszMenuName  = lpszAppName;              
  55.    wc.lpszClassName = lpszAppName;              
  56.  
  57.    if ( IS_WIN95 )
  58.    {
  59.       if ( !RegisterWin95( &wc ) )
  60.          return( FALSE );
  61.    }
  62.    else if ( !RegisterClass( &wc ) )
  63.       return( FALSE );
  64.  
  65.    hInst = hInstance; 
  66.  
  67.    hWnd = CreateWindow( lpszAppName, 
  68.                         lpszTitle,    
  69.                         WS_OVERLAPPEDWINDOW, 
  70.                         CW_USEDEFAULT, 0, 
  71.                         CW_USEDEFAULT, 0,  
  72.                         NULL,              
  73.                         NULL,              
  74.                         hInstance,         
  75.                         NULL               
  76.                       );
  77.  
  78.    if ( !hWnd ) 
  79.       return( FALSE );
  80.  
  81.    ShowWindow( hWnd, nCmdShow ); 
  82.    UpdateWindow( hWnd );         
  83.  
  84.    while( GetMessage( &msg, NULL, 0, 0) )   
  85.    {
  86.       TranslateMessage( &msg ); 
  87.       DispatchMessage( &msg );  
  88.    }
  89.  
  90.    return( msg.wParam ); 
  91. }
  92.  
  93.  
  94. BOOL RegisterWin95( CONST WNDCLASS* lpwc )
  95. {
  96.     WNDCLASSEX wcex;
  97.  
  98.    wcex.style         = lpwc->style;
  99.    wcex.lpfnWndProc   = lpwc->lpfnWndProc;
  100.    wcex.cbClsExtra    = lpwc->cbClsExtra;
  101.    wcex.cbWndExtra    = lpwc->cbWndExtra;
  102.    wcex.hInstance     = lpwc->hInstance;
  103.    wcex.hIcon         = lpwc->hIcon;
  104.    wcex.hCursor       = lpwc->hCursor;
  105.    wcex.hbrBackground = lpwc->hbrBackground;
  106.    wcex.lpszMenuName  = lpwc->lpszMenuName;
  107.    wcex.lpszClassName = lpwc->lpszClassName;
  108.  
  109.    // Added elements for Windows 95.
  110.    //...............................
  111.    wcex.cbSize = sizeof(WNDCLASSEX);
  112.    wcex.hIconSm = LoadImage(wcex.hInstance, lpwc->lpszClassName, 
  113.                             IMAGE_ICON, 16, 16,
  114.                             LR_DEFAULTCOLOR );
  115.             
  116.    return RegisterClassEx( &wcex );
  117. }
  118.  
  119. #define CONFCALL    1
  120. #define CONSULT      2
  121.  
  122. enum CallState
  123. {
  124.     Idle,
  125.     Offering,
  126.     Accepted,
  127.     Dialtone,
  128.     Dialing,
  129.     Ringback,
  130.     Busy,
  131.     Special,
  132.     Connected,
  133.     Proceeding,
  134.     Conferenced,
  135.     Onholdconf,
  136.     Disconnected,
  137.     Unknown
  138. };
  139.  
  140. typedef struct tagMYINFO      // general application information
  141. {
  142.     HLINEAPP lineApp;         // instance handle TAPI gives back to us                                                                              through lineInitialize()
  143.     DWORD dwNumDevices;       // number of available devices
  144.     DWORD dwAPIVersion;       // API version the line supports
  145.      DWORD dwExtVersion;           // extended version
  146.     char szLocation[128];     // location        
  147.      char szCallingCard[128];  // calling card being used
  148.     char szAreaCode[4];       // area code       
  149.     char szCountry[128];      // calling card being used
  150. } MYINFO;
  151.  
  152. typedef struct tagLINEINFO  // information on an open line
  153. {
  154.     DWORD dwNumAddress;     // number of available addresses on the line 
  155.     HLINE hLine;            // handle to the line as returned by lineOpen 
  156.      DWORD dwLineID;         // the line ID of this line
  157.     char  szLineName[128];  // the line's name 
  158.  
  159. } MYLINEINFO;
  160.  
  161. typedef struct tagMYCALLINFO  //information on a call                     
  162. {
  163.     
  164. DWORD       eCallState;    // TAPI's line call State, set as user-defined enums
  165. DWORD      dwRequestID;   // requestID returned by async TAPI functions lineMakeCall/lineDropCall
  166. DWORD      dwAddressID;   // the originating address ID of the call being made 
  167. LPCSTR     lpszAddress;    
  168. HLINE     hLine;         // handle to the line 
  169. HCALL        hCall;         // handle to the call 
  170.    
  171. char szDialString[TAPIMAXDESTADDRESSSIZE];  //phone number being dialed
  172. char szDialStringOriginal[TAPIMAXDESTADDRESSSIZE];
  173. char szDialStringCanonical[TAPIMAXDESTADDRESSSIZE];
  174. char szCalledParty[TAPIMAXCALLEDPARTYSIZE]; // name of the party
  175. DWORD dwTranslateResults;
  176.         
  177. } MYCALLINFO;
  178.  
  179. enum CallAction     // Declare enum type CallAction (used in lineSetAppSpecific)
  180. {
  181.    HOLD,            // hold the call
  182.    TRANSFER,        // transfer the call
  183.    REDIRECT,        // redirect the call
  184.    DROP,            // drop the call
  185.    PARK             // park the call
  186. }; 
  187.  
  188. MYINFO myInfo;          //instance of MYINFO structure
  189. MYLINEINFO myLineInfo[MAX_LINE];  //instance of MYLINEINFO structure
  190. MYCALLINFO myCallInfo[MAX_CALL]; //array of MYCALLINFO strcuture
  191.  
  192. LONG lRet;        //return code
  193. char buf[BUFSIZE];    // buffer for debug message
  194.  
  195. DWORD dwLineID = 0;
  196. DWORD i;
  197. LINEEXTENSIONID        ext_id;
  198. LINEDEVCAPS            *plineDevCaps;
  199. LINEADDRESSCAPS        *plineAddressCaps;
  200. LINEADDRESSSTATUS     *plineAddressStat;
  201. LINECALLINFO            *plineCallInfo;
  202. LINECALLSTATUS         *plineCallStatus;
  203. LINECALLLIST            *plineCallList;
  204. LINEDEVSTATUS           *plineDevStatus;
  205. LINETRANSLATECAPS       *plineTranslateCaps;
  206. LINETRANSLATEOUTPUT  *plineTranslateOutput;
  207. LINECALLPARAMS           *plineCallParams;
  208. LINEDEVSTATUS           *plineDevStatus;
  209. LINEFORWARDLIST        *plineForwardList;
  210. LINETRANSLATECAPS       *plineTranslateCaps;
  211. LINEREQMAKECALL       lineReqMakeCall;
  212. VARSTRING               *pDeviceConfig;
  213. VARSTRING               *pDeviceId;
  214. VARSTRING               *pNonDirAddress;
  215.  
  216. LPLINELOCATIONENTRY  lineLocEntry;
  217. LPLINECARDENTRY        lineCardEntry;
  218. LINECOUNTRYLIST         *plineCountryList;
  219. LPLINECOUNTRYENTRY   lineCE;
  220.  
  221. LPSTR                lpData;
  222. DWORD                dwLineStates, dwAddressStates;
  223.  
  224. HICON                hIcon = NULL;        //used in lineGetID();
  225. DWORD                dwNumRings;    //used in lineGetStatusMessages();
  226. HCALL                hConsultCall; //handle to consultation linePrepareAddToConference, SetupConference
  227. HCALL                hConfCall; //handle to consultation linePrepareAddToConference, SetupConference   
  228. HCALL                hParkedCall;
  229.  
  230. DWORD                dwCompletionID;  //used in lineCompleteCall()
  231.  
  232. char                szName[128];
  233. char                szNumber[128];
  234. char                szDigits[128];
  235. char                szDevConfig[128];
  236.  
  237. LONG lRet;
  238. char buf[BUFSIZE];
  239.  
  240. LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
  241. {
  242.    switch( uMsg )
  243.    {
  244.       case WM_COMMAND :
  245.          switch( LOWORD( wParam ) )
  246.          {
  247.             case IDM_RUN :
  248.       
  249.             // tell tapi that we are interested in CONNECTED messages        
  250.             //  for the line and NUMCALL messages for the address
  251.             //............................
  252.             lRet = lineSetStatusMessages (myLineInfo->hLine,                      
  253.                             LINEDEVSTATE_CONNECTED, LINEADDRESSSTATE_NUMCALLS);
  254.             if (lRet == 0)
  255.             {
  256.                wsprintf (buf, "lineSetStatusMessages succeeded!");
  257.                SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  258.                
  259.                lRet = lineGetStatusMessages(myLineInfo->hLine,                          
  260.                                               &dwLineStates, &dwAddressStates);
  261.                if (lRet == 0)
  262.                {
  263.                   wsprintf (buf, "lineGetStatusMessages succeeded!");
  264.                   SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  265.  
  266.                   if (dwLineStates & LINEDEVSTATE_CONNECTED)
  267.                   {
  268.                      wsprintf (buf, "This line can receive LINEDEVSTATE_CONNECTED messages!");
  269.                      SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  270.                   }
  271.                   
  272.                   if (dwAddressStates & LINEADDRESSSTATE_NUMCALLS)
  273.                   {
  274.                      wsprintf (buf, "This address can receive LINEADDRESSSTATE_NUMCALLS messages!");
  275.                      SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  276.                   }
  277.                }
  278.                else 
  279.                {
  280.                   wsprintf ( buf,"lineGetStatusMessages failed, err=x%lx", 
  281.                              lRet);
  282.                   lineError(lRet);
  283.                }
  284.             }
  285.             else 
  286.             {
  287.                wsprintf ( buf,"lineSetStatusMessages failed, err=x%lx",                   
  288.                           lRet);
  289.                lineError(lRet);
  290.             }
  291.  
  292.             break;
  293.  
  294.             case IDM_ABOUT :
  295.             {
  296.                 DialogBox( hInst, "AboutBox", hWnd, (DLGPROC)About );
  297.                break;
  298.             }
  299.  
  300.             case IDM_EXIT :
  301.             {
  302.                for (i = 0; i < myInfo.dwNumDevices; i++)
  303.                        lineClose(myLineInfo[i].hLine);
  304.                     lineShutdown(myInfo.lineApp);
  305.                DestroyWindow( hWnd );
  306.                break;
  307.             }
  308.             }                  
  309.                  
  310.          break;
  311.  
  312.       case WM_CREATE :
  313.       {
  314.          hdc = GetDC (hWnd) ;
  315.          GetTextMetrics (hdc, &tm) ;
  316.          ReleaseDC (hWnd, hdc) ;
  317.  
  318.          hListWnd = CreateWindowEx( 0, "listbox", 
  319.                         " ",    
  320.                         WS_CHILD | WS_VISIBLE,  
  321.                         tm.tmAveCharWidth, tm.tmHeight * 3, 
  322.                         tm.tmAveCharWidth * 16 +
  323.                                    GetSystemMetrics (SM_CXVSCROLL), 
  324.                         tm.tmHeight * 5,  
  325.                         hWnd,              
  326.                         NULL,              
  327.                         hInst,         
  328.                         NULL               
  329.                         );
  330.  
  331.          
  332.          //lineInitialize
  333.             //...............................................
  334.          lRet = lineInitialize(&myInfo.lineApp, hInst, lineCallback, NULL, &myInfo.dwNumDevices);
  335.          if (lRet == 0) 
  336.          {
  337.             wsprintf (buf, "lineInitialize suceeded!");
  338.               SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  339.            }
  340.          else 
  341.           {
  342.                wsprintf ( buf,"lineInitialize failed, err=x%lx",lRet);
  343.                SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  344.                lineError(lRet);
  345.                break;
  346.          }                    
  347.          
  348.          //lineNegotiateAPIVersion
  349.           //...............................................
  350.          lRet = lineNegotiateAPIVersion(myInfo.lineApp, 0, APILOWVERSION, APIHIVERSION, 
  351.                                            &myInfo.dwAPIVersion, &ext_id);
  352.          if (lRet == 0)                        
  353.          {
  354.             wsprintf (buf, "lineNegotiateAPIVersion suceeded!");
  355.               SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  356.          }
  357.          else 
  358.           {
  359.                wsprintf (buf, "lineNegotiateAPIVersion failed, err=x%lx",
  360.                            lRet);
  361.                SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  362.                lineError(lRet);
  363.                lineShutdown (myInfo.lineApp);
  364.             break;
  365.          }
  366.  
  367.           //lineNegotiateExtVersion
  368.           //...............................................
  369.          lRet = lineNegotiateExtVersion(myInfo.lineApp, 0, myInfo.dwAPIVersion, EXTLOWVERSION, 
  370.                                            EXTHIVERSION, &myInfo.dwExtVersion);
  371.          if (lRet == 0)                        
  372.          {
  373.             wsprintf (buf, "lineNegotiateExtVersion suceeded!");
  374.             SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  375.  
  376.          }
  377.           else 
  378.           {
  379.                wsprintf (buf, "lineNegotiateExtVersion failed, err=x%lx",
  380.                      lRet);
  381.               SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  382.               lineError(lRet);
  383.       
  384.          }
  385.  
  386.           //lineGetDevCaps
  387.           //for each line device, get capabilities until we find one that supports
  388.          //interactive voice 
  389.           //...............................................
  390.          plineDevCaps = (LINEDEVCAPS *) calloc (1, sizeof(LINEDEVCAPS)+1000);
  391.          plineDevCaps->dwTotalSize = sizeof(LINEDEVCAPS) + 1000;
  392.          for (i = 0; i < myInfo.dwNumDevices; i++)
  393.          {
  394.             lineGetDevCaps(myInfo.lineApp, i, myInfo.dwAPIVersion, 0, plineDevCaps);
  395.             if (plineDevCaps->dwMediaModes & LINEMEDIAMODE_INTERACTIVEVOICE) 
  396.             {
  397.                
  398.                myLineInfo[i].dwNumAddress = plineDevCaps->dwNumAddresses;
  399.                   myLineInfo[i].dwLineID = i;
  400.                    if (plineDevCaps->dwLineNameSize > 0)
  401.                           strcpy(myLineInfo[i].szLineName,((LPSTR)(plineDevCaps)+plineDevCaps->dwLineNameOffset));
  402.              }
  403.           }
  404.  
  405.          //lineOpen
  406.           //................................................................
  407.           lRet = lineOpen(myInfo.lineApp,myLineInfo[OWNER].dwLineID,&myLineInfo[OWNER].hLine,
  408.                            myInfo.dwAPIVersion,0,(DWORD)lineCallback, LINECALLPRIVILEGE_NONE,
  409.                             LINEMEDIAMODE_DATAMODEM, NULL);
  410.           if (lRet == 0)
  411.           {
  412.             wsprintf (buf, "lineOpen suceeded!");
  413.             SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;         }
  414.            else 
  415.            {
  416.                wsprintf ( buf,"lineOpen failed, err=x%lx", lRet);
  417.                SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  418.                lineError(lRet);
  419.           }
  420.        
  421.          break;
  422.       }
  423.       
  424.       case WM_SIZE:
  425.           MoveWindow(hListWnd,0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
  426.          break;
  427.  
  428.       case WM_DESTROY :
  429.               PostQuitMessage(0);
  430.               break;
  431.  
  432.       default :
  433.             return( DefWindowProc( hWnd, uMsg, wParam, lParam ) );
  434.    }
  435.  
  436.    return( 0L );
  437. }
  438.  
  439.  
  440.  
  441.  
  442. /****************************************************************************
  443.     FUNCTION: lineCallback
  444.     PURPOSE:  callback function handles line events
  445. ****************************************************************************/
  446. LRESULT CALLBACK lineCallback (DWORD dwDevice, DWORD dwMsg,
  447.                                        DWORD dwCallbackInst, DWORD dwParam1,
  448.                                        DWORD dwParam2,DWORD dwParam3)
  449. {
  450.    switch (dwMsg)
  451.    {
  452.       case LINE_CALLSTATE:
  453.        {
  454.             for (i = 0; i < MAX_CALL; i++)
  455.            {
  456.                 if (dwDevice = (DWORD) myCallInfo[i].hCall) 
  457.                  switch (dwParam1)
  458.                  {
  459.                     case LINECALLSTATE_IDLE:
  460.                         myCallInfo[i].eCallState = Idle;
  461.                   break;
  462.                     
  463.                     case LINECALLSTATE_OFFERING:
  464.                   myCallInfo[i].eCallState = Offering;
  465.                   break;
  466.                                    
  467.                     case LINECALLSTATE_ACCEPTED:
  468.                         myCallInfo[i].eCallState = Accepted;
  469.                         break;
  470.                     
  471.                     case LINECALLSTATE_DIALTONE:
  472.                         myCallInfo[i].eCallState = Dialtone;
  473.                   break;
  474.                     
  475.                     case LINECALLSTATE_DIALING:
  476.                         myCallInfo[i].eCallState = Dialing;
  477.                         break;
  478.                   
  479.                   case LINECALLSTATE_RINGBACK:
  480.                         myCallInfo[i].eCallState = Ringback;
  481.                         break;
  482.             
  483.                     case LINECALLSTATE_BUSY:
  484.                         myCallInfo[i].eCallState = Busy;
  485.                         break;
  486.             
  487.                     case LINECALLSTATE_SPECIALINFO:
  488.                         myCallInfo[i].eCallState = Special;
  489.                        break;
  490.             
  491.                     case LINECALLSTATE_CONNECTED:
  492.                        myCallInfo[i].eCallState = Connected;
  493.                   break;
  494.  
  495.                     case LINECALLSTATE_PROCEEDING:
  496.                         myCallInfo[i].eCallState = Proceeding;
  497.                        break;
  498.             
  499.                     case LINECALLSTATE_CONFERENCED:
  500.                         myCallInfo[i].eCallState = Conferenced;
  501.                        break;
  502.             
  503.                     case LINECALLSTATE_ONHOLDPENDCONF:
  504.                         break;
  505.                 
  506.                case LINECALLSTATE_DISCONNECTED:
  507.                         myCallInfo[i].eCallState = Disconnected;
  508.                        break;
  509.             
  510.                     case LINECALLSTATE_UNKNOWN:
  511.                         myCallInfo[i].eCallState = Unknown;
  512.                        break;
  513.        
  514.              }
  515.           }
  516.        }
  517.  
  518.        case LINE_MONITORMEDIA:
  519.            break;
  520.  
  521.        case LINE_MONITORDIGITS:
  522.           break;
  523.  
  524.          case LINE_MONITORTONE:
  525.           break;
  526.    
  527.        //error handling for functions completed asynchronously
  528.         //.....................................................
  529.        case LINE_REPLY:
  530.         {
  531.             for (i = 0; i < MAX_CALL; i++)
  532.            {
  533.                 if (dwParam1 = myCallInfo[i].dwRequestID)
  534.                {
  535.                    if (dwParam2 != 0)
  536.                    {
  537.                        lineError((LONG) dwParam2);
  538.                        break;
  539.                    }
  540.                }
  541.            }
  542.         break;
  543.         }
  544.  
  545.         case LINE_GENERATE:
  546.           break;
  547.      
  548.        case LINE_REQUEST:
  549.          break;
  550.  
  551.         case LINE_GATHERDIGITS:
  552.            break;
  553.    }
  554.  
  555.    return (TRUE);
  556.  
  557.  
  558. /****************************************************************************
  559.     FUNCTION: lineError
  560.     PURPOSE:  line error messages
  561. ****************************************************************************/
  562. void lineError (LONG lrc)
  563. {
  564.  switch (lrc) {
  565.     case LINEERR_INVALAPPHANDLE:
  566.        MessageBox (hWnd, "Invalid app handle.", "", MB_OK);
  567.        break;
  568.     case LINEERR_BADDEVICEID:
  569.        MessageBox (hWnd,"The specified line device ID is out of range.", "", 
  570.                    MB_OK);
  571.        break;
  572.     case LINEERR_INCOMPATIBLEAPIVERSION:
  573.        MessageBox (hWnd, "Incompatible API version.", "", MB_OK);
  574.        break;
  575.     
  576.     case LINEERR_ADDRESSBLOCKED:
  577.        MessageBox (hWnd, "Address was blocked.", "", MB_OK);
  578.        break;
  579.  
  580.     case LINEERR_BEARERMODEUNAVAIL:
  581.        MessageBox (hWnd, "Bearer Mode Unavailable.", "", MB_OK);
  582.        break;
  583.  
  584.     case LINEERR_CALLUNAVAIL:
  585.        MessageBox (hWnd, "Call appearances in use..", "", MB_OK);
  586.        break;
  587.  
  588.     case LINEERR_INUSE:
  589.        MessageBox (hWnd, "Line in Use.", "", MB_OK);
  590.        break;
  591.     
  592.     case LINEERR_INVALADDRESS:
  593.        MessageBox (hWnd, "Invalid Address.", "", MB_OK);
  594.        break;
  595.  
  596.     case LINEERR_INVALADDRESSID:
  597.        MessageBox (hWnd, "Invalid Address ID.", "", MB_OK);
  598.        break;
  599.  
  600.     case LINEERR_INVALCALLPARAMS:
  601.        MessageBox (hWnd, "Invalid Address ID.", "", MB_OK);
  602.        break;
  603.      
  604.     case LINEERR_INCOMPATIBLEEXTVERSION:
  605.        MessageBox (hWnd, "Incompatible extension version.","", MB_OK);
  606.        break;
  607.     case LINEERR_NOMEM:
  608.        MessageBox (hWnd, "No memory","", MB_OK);
  609.        break;
  610.     case LINEERR_NODRIVER:
  611.        MessageBox (hWnd, "No driver loaded", "", MB_OK);
  612.        break;
  613.     case LINEERR_RESOURCEUNAVAIL:
  614.        MessageBox (hWnd, "Resource overcommittment", "", MB_OK);
  615.        break;
  616.     case LINEERR_INVALPRIVSELECT:
  617.        MessageBox (hWnd, "Requested invalid priviledges", "", MB_OK);
  618.        break;
  619.     case LINEERR_INVALMEDIAMODE:
  620.        MessageBox (hWnd, "Requested invalid media mode", "", MB_OK);
  621.        break;
  622.     case LINEERR_LINEMAPPERFAILED:
  623.        MessageBox (hWnd, "Line mapper failed", "", MB_OK);
  624.        break;
  625.     case LINEERR_INVALPOINTER:
  626.        MessageBox (hWnd, "The specified pointer parameter is invalid.",
  627.                    "", MB_OK);
  628.        break;
  629.     case LINEERR_OPERATIONFAILED:
  630.        MessageBox (hWnd, "Operation failed.", "", MB_OK);
  631.        break;
  632.     case LINEERR_INVALLINEHANDLE:
  633.        MessageBox (hWnd, "Invalid line handle", "", MB_OK);
  634.        break;
  635.     case LINEERR_INVALCALLHANDLE:
  636.        MessageBox (hWnd, "Invalid call handle", "", MB_OK);
  637.        break;
  638.     case LINEERR_INVALCALLSELECT:
  639.        MessageBox (hWnd, "Invalid call selection", "", MB_OK);
  640.        break;
  641.     case LINEERR_NODEVICE:
  642.        MessageBox (hWnd, "No associated device for given class",
  643.                    "", MB_OK);
  644.        break;
  645.     case LINEERR_OPERATIONUNAVAIL:
  646.        MessageBox (hWnd, "The operation is unavailable",
  647.                    "", MB_OK);
  648.        break;
  649.     case LINEERR_INVALPARAM:
  650.         MessageBox(hWnd, "Invalid Paramater", "", MB_OK);
  651.        break; 
  652.  
  653.     case LINEERR_TARGETNOTFOUND:
  654.         MessageBox(hWnd, "Target Not Found", "", MB_OK);
  655.        break; 
  656.  
  657.    case LINEERR_NOREQUEST:
  658.       MessageBox(hWnd, "No outstanding Assisted Telephony requests.", "", MB_OK);
  659.        break; 
  660.    }
  661. }
  662.  
  663. LRESULT CALLBACK Dial ( HWND hDlg,           // window handle of the dialog box
  664.                         UINT message,        // type of message
  665.                         WPARAM wParam,       // message-specific information
  666.                         LPARAM lParam)
  667. {
  668.    switch (message) 
  669.    {
  670.        case WM_INITDIALOG:  // message: initialize dialog box
  671.                return (TRUE);
  672.  
  673.        case WM_COMMAND:                              // message: received a command
  674.          if (   LOWORD(wParam) == IDOK )        // "OK" box selected?
  675.          {
  676.             GetDlgItemText(hDlg, IDC_NAME, szName, 128);
  677.                 GetDlgItemText(hDlg, IDC_NUMBER, szNumber, 128);
  678.                                       
  679.  
  680.                 // put up a dialog box to obtain a string to dial from the user
  681.                //...........................................................
  682.                strcpy(myCallInfo[0].szDialStringOriginal, szNumber); 
  683.                
  684.                //allocate buffer for the LINEADDRESSCAPS strucuture 
  685.                //...................................................
  686.                plineTranslateOutput = (LINETRANSLATEOUTPUT *) calloc (1, sizeof(LINETRANSLATEOUTPUT)+1000);
  687.             plineTranslateOutput->dwTotalSize = sizeof(LINETRANSLATEOUTPUT) + 1000;
  688.               
  689.                // translate the Address to a dialable address and Canonical address
  690.                //.....................................................................
  691.                lRet = lineTranslateAddress(myInfo.lineApp, myLineInfo[OWNER].dwLineID, myInfo.dwAPIVersion,
  692.                                            myCallInfo[0].szDialStringOriginal, 0, 0, plineTranslateOutput);
  693.                               
  694.                if (lRet == 0)
  695.                {
  696.                        
  697.                    strncpy(myCallInfo[0].szDialString, (LPSTR)(plineTranslateOutput)
  698.                             + plineTranslateOutput->dwDialableStringOffset,
  699.                              plineTranslateOutput->dwDialableStringSize); 
  700.     
  701.                     strncpy(myCallInfo[0].szDialStringCanonical,(LPSTR)(plineTranslateOutput) 
  702.                             + plineTranslateOutput->dwDisplayableStringOffset,
  703.                             plineTranslateOutput->dwDisplayableStringSize); 
  704.                                            
  705.                    myCallInfo[0].dwTranslateResults = plineTranslateOutput->dwTranslateResults;
  706.                 }
  707.  
  708.                else 
  709.                {
  710.                     wsprintf ( buf,"lineTranslateAddress failed, err=x%lx", lRet);
  711.                     lineError(lRet);
  712.                    break;
  713.             }
  714.            
  715.                //lineMakeCall
  716.                //................................................................
  717.                           
  718.                plineCallParams = (LINECALLPARAMS *) calloc (1, sizeof(LINECALLPARAMS)+1000);
  719.             plineCallParams->dwTotalSize = sizeof(LINECALLPARAMS) + 1000;
  720.  
  721.                plineCallParams->dwBearerMode = LINEBEARERMODE_VOICE;
  722.                plineCallParams->dwMediaMode =  LINEMEDIAMODE_DATAMODEM;
  723.                plineCallParams->dwCallParamFlags = LINECALLPARAMFLAGS_IDLE;
  724.                plineCallParams->dwAddressMode    = LINEADDRESSMODE_ADDRESSID;
  725.                plineCallParams->dwAddressID    = 0;
  726.                plineCallParams->dwMinRate    = 1200;
  727.                plineCallParams->dwMaxRate    = 2400;
  728.                             
  729.                lRet = lineMakeCall(myLineInfo[OWNER].hLine,&myCallInfo[0].hCall, 
  730.                                       myCallInfo[0].szDialString ,0,  plineCallParams);
  731.            
  732.             if (lRet > 0)
  733.                {
  734.                wsprintf (buf, "lineMakeCall suceeded!");
  735.                SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;               
  736.                    myCallInfo[0].dwRequestID = lRet;
  737.                 }
  738.             else 
  739.                {
  740.                    wsprintf ( buf,"lineMakeCall failed, err=x%lx", lRet);
  741.                     lineError(lRet);
  742.                    break;
  743.             }
  744.             
  745.             EndDialog(hDlg, TRUE);        // Exit the dialog
  746.             return (TRUE);
  747.          }
  748.  
  749.             if (   LOWORD(wParam) == IDCANCEL)         // "OK" box selected?
  750.          {
  751.             EndDialog(hDlg, TRUE);        // Exit the dialog
  752.             return (TRUE);
  753.          }
  754.          break;
  755.  
  756.  
  757.    }
  758.  
  759.    return (FALSE); 
  760. }
  761.  
  762.  
  763. LRESULT CALLBACK About( HWND hDlg,           
  764.                         UINT message,        
  765.                         WPARAM wParam,       
  766.                         LPARAM lParam)
  767. {
  768.    switch (message) 
  769.    {
  770.        case WM_INITDIALOG: 
  771.                return (TRUE);
  772.  
  773.        case WM_COMMAND:                              
  774.                if (   LOWORD(wParam) == IDOK         
  775.                    || LOWORD(wParam) == IDCANCEL)    
  776.                {
  777.                        EndDialog(hDlg, TRUE);        
  778.                        return (TRUE);
  779.                }
  780.                break;
  781.    }
  782.  
  783.    return (FALSE); 
  784. }
  785.  
  786.  
  787.  
  788.